package org.domus.sipnmove.useragent.view;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import org.domus.sipnmove.useragent.Call;
import org.domus.sipnmove.useragent.CallObserver;

/**
 * Represents a user agent
 */
@SuppressWarnings("serial")
public class CallView extends JFrame implements CallObserver, WindowListener, ActionListener {

	private Call call;

	public CallView(Call call) {
		this.call = call;
		init();
	}

	/**
	 * Initialize the view
	 */
	private void init() {

		this.setSize(300, 400);

		this.getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

		JLabel contactLabel = new JLabel("sip:contact@contact");
		contactLabel.setPreferredSize(new Dimension(300, 30));
		this.getContentPane().add(contactLabel);

		JTextArea contentTextArea = new JTextArea("Hello !");
		contentTextArea.setPreferredSize(new Dimension(300, 300));
		this.getContentPane().add(contentTextArea);

		JTextField inputTextField = new JTextField("Votre message...");
		inputTextField.setPreferredSize(new Dimension(300, 30));
		this.getContentPane().add(inputTextField);

		JButton okButton = new JButton("OK");
		okButton.setPreferredSize(new Dimension(300, 40));
		okButton.addActionListener(new OkButtonActionListener());
		this.getContentPane().add(okButton);

		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		this.addWindowListener(this);

		this.pack();

	}

	@Override
	public void windowActivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowClosed(WindowEvent arg0) {
		call.terminate();
	}

	@Override
	public void windowClosing(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeactivated(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowDeiconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowIconified(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void windowOpened(WindowEvent arg0) {
		// TODO Auto-generated method stub

	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub

	}

}
